<?php include('./templete/public/head.php') ?>
<form action="<?php echo url('index') ?>" method="get">
    <div class="header">
        <div class="seek">
            <input type="text" id="name" name="name" value="<?php echo input('name') ?>" placeholder="请输入搜索内容" onchange="search()"/>
            <a class="iconfont seekfont fr">&#xe60d;</a>
        </div>
    </div>
</form>
<hr style="height: .45rem;border: none;margin: 0;"/>
<hr class="writ" style="height:.4rem;"/>
<div class="bgpic smpic" style="background-image: url(<?php echo $banner['img_url']?>);"></div>
<hr class="eee"/>
<div class="index-main">
    <?php foreach ($list as $v){ ?>
        <dl class="clearfix">
            <a href="<?php echo url('detail?id='.$v['id']) ?>">
                <dd class="fl"><i style="display:inline-block;background-image:url(<?php echo $v['imgpath'] ?>);height:104px;width:100%;background-repeat: no-repeat;
                        background-position: center;    background-size: auto 104px;"></i></dd>
                <dt class="fr">
                    <h1><?php echo $v['name'] ?></h1>
                    <p><?php echo $v['description'] ?></p>
                </dt>
            </a>
        </dl>
    <?php } ?>
</div>
<!--footer-->
<script type="text/javascript">

    var mySwiper = new Swiper ('.swiper-container', {
        loop: true,
        autoplay : 2000,

        // 如果需要分页器
        pagination: '.swiper-pagination',
    })
    $(function() {
        var page = 2;
        var load_flag = true;
        $(window).scroll(function() {
            var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop());
            var documentheight = parseFloat($(document).height());
            var name=$('#name').val();
            if (documentheight - totalheight <= 200) {
                $("#loadmore").show();
                if(load_flag){
                    load_flag=!load_flag;
                    $.ajax({
                        url: '/index/knowledge/index_page.html',
                        type: 'post',
                        dataType: 'json',
                        data: {
                            page:page,
                            name:name
                        },
                        success: function(data) {
                            if (data.length) {
                                $.each(data,function(k, v) {
                                    var html = '<dl class="clearfix">' + '<a href="/index/index/detail?id='+v['id']+'">' + '<dd class="fl"><img src="'+v['imgpath']+'"/></dd>' + '<dt class="fr">' + '<h1>' + v['name'] + '</h1>' + '<p>' + v['description'] + '</p>' + '</dt>' + ' </a>' + '</dl>';
                                    $(".index-main").append(html);
                                })
                                load_flag=!load_flag;
                                page++;
                            }
                        }
                    })
                }

            }
        });
    });
	function search(){
	var name = $('#name').val();
	window.location.href="/index/knowledge/index.html?name="+name;
	// $.ajax({
		// url:'/index/index/search.html',
		// type:'get',
		// dataType:'json',
		// data:{
			// name:name
		// },
		// success:function(data){
			// if(data.length){
				// $('.index-main').html("");
				// $.each(data,function(k,v){
					// var str = '<dl class="clearfix">' + '<a href="/index/index/detail?id='+v['id']+'">' + '<dd class="fl"><img src="'+v['imgpath']+'"/></dd>' + '<dt class="fr">' + '<h1>' + v['name'] + '</h1>' + '<p>' + v['description'] + '</p>' + '</dt>' + ' </a>' + '</dl>';
					// $('.index-main').append(str);
				// })
			// }
		// }
	// })
}

</script>
</script>
<?php include('./templete/public/foot.php') ?>

